package com.tuanzi.loan.web.bean.statistics.union;

import com.google.common.collect.Lists;
import com.tuanzi.loan.business.constants.DictionaryCode;
import com.tuanzi.loan.core.aspect.Debug;
import com.tuanzi.loan.vo.request.statistics.union.NewUnionLoginStatRequest;
import com.tuanzi.loan.vo.response.statistics.union.NewUnionLoginStatResponse;
import com.tuanzi.loan.web.configuration.JSFListingBean;
import com.tuanzi.loan.web.lazy.statistics.union.NewUnionLoginStatLazyDataModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.joda.time.LocalDate;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.faces.bean.ViewScoped;
import java.util.List;

/**
 * User: liangZongXi
 * Create time: 10:53 2019/9/10
 * Description:
 */
@Debug
@Data
@Component
@ViewScoped
@EqualsAndHashCode(callSuper = true)
public class NewUnionLoginStatBean extends JSFListingBean<NewUnionLoginStatRequest, NewUnionLoginStatResponse> {
    private static final long serialVersionUID = 5656324436748028050L;


    @PostConstruct
    private void init(){
        initLazyDataModel();
    }

    private void initLazyDataModel() {
        $ = new NewUnionLoginStatRequest();
        LocalDate now = LocalDate.now();
        LocalDate before = now.plusDays(-1);
        $.setBeginDate(before.toDate());
        $.setEndDate(now.toDate());
        lazyDataModel = new NewUnionLoginStatLazyDataModel($);
    }

    public void onReset(){
        init();
    }


    @Override
    protected List<String> getDictionaryCodes() {
        return Lists.newArrayList(DictionaryCode.LARGE_COMMON_PRODUCT);
    }
}
